<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <p ref="life" @click="handleClick">{{msg}}</p>
    </div>
    <script>
        new Vue({
            el: "#app",
            data: {
                msg: "hello world"
            },
            methods: {
                handleClick(){
                    this.msg = "change"
                }
            },
            // vue实例被创建之前
            beforeCreate() {
                console.log("beforeCreate");
                console.log(this.$refs.life);
            },
            // vue实例被创建之后
            created() {
                console.log("created");
                console.log(this.$refs.life);
            },
            beforeMount() {
                console.log("beforeMount");
                console.log(this.$refs.life);
            },
            mounted() {
                console.log("mounted");
                console.log(this.$refs.life);
            },
            beforeUpdate() {
                console.log("beforeUpdate");
            },
            updated() {
                console.log("updated");
            },
        })
    </script>
</body>

</html>